//
//  KALimitPlate.swift
//  kano
//
//  Created by Sophia on 2024/8/21.
//

import UIKit

class KALimitPlate: UIView {
    lazy var var_titleLabel: UILabel = {
        let var_titleLabel = UILabel()
        var_titleLabel.font = UIFont.systemFont(ofSize: kscale(13), weight: .medium)
        var_titleLabel.textColor = .black
        var_titleLabel.text = "Credit limit"
        var_titleLabel.frame = CGRectMake(kscale(10), kscale(20), width-kscale(20), kscale(16))
        return var_titleLabel
    }()

    lazy var var_cashLabel: UILabel = {
        let var_cashLabel = UILabel()
        var_cashLabel.font = UIFont.systemFont(ofSize: kscale(14), weight: .regular)
        var_cashLabel.textColor = .themeColor
        var_cashLabel.text = "₦ 0"
        return var_cashLabel
    }()
    lazy var var_arrowImg: UIImageView = {
        let var_arrowImg = UIImageView(image: UIImage(named: "mine_arrow"))
        var_arrowImg.size = CGSize(width: kscale(24), height: kscale(24))
        return var_arrowImg
    }()
}

extension KALimitPlate {
    convenience init(_ frame:CGRect) {
        self.init(frame: frame)
        ka_setUI()
    }
    
    func ka_setUI() {
        backgroundColor = .colorFFF
        ka_addShadowAndCornerRadius(cornerRadius: kscale(8), shadowColor: .colorf2f2f5, shadowOpacity: 1, shadowOffset: CGSize(width: 0, height: 0), shadowRadius: kscale(8))
        addSubview(var_titleLabel)
        addSubview(var_cashLabel)
        addSubview(var_arrowImg)
        
        var_cashLabel.snp.makeConstraints { make in
            make.left.equalTo(kscale(10))
            make.top.equalTo(var_titleLabel.snp.bottom).offset(kscale(7))
        }
        var_arrowImg.snp.makeConstraints { make in
            make.size.equalTo(CGSizeMake(kscale(16), kscale(16)))
            make.centerY.equalTo(var_cashLabel.snp.centerY)
            make.left.equalTo(var_cashLabel.snp.right).offset(kscale(4))
        }
    }
}
